package engine.newUi
{
	import engine.data.BindManage;
	import engine.data.ModelLocator;
	import engine.data.ObjectData;
	import engine.data.Record;
	import engine.data.ResPath;
	import engine.data.RoleVo;
	import engine.data.View;
	import engine.data.ViewObject;
	import engine.event.SoundEvent;
	import engine.flag.GameDefine;
	import engine.flag.ResourcesPath;
	import engine.logic.DoubleClickManager;
	import engine.logic.McPool;
	import engine.logic.MenuListManager;
	import engine.logic.event.LogicEvent;
	import engine.net.event.CustomMsgEvent;
	import engine.net.messages.CustomToClientFlag;
	import engine.net.messages.CustomToServerFlag;
	import engine.net.mgr.SystemSender;
	import engine.scene.SceneManager;
	import engine.tip.TipsMainLogic;
	import engine.tip.tipItem.EquipItem;
	import engine.tip.tipItem.KungfuItem;
	import engine.tip.tipItem.PetTipItem;
	import engine.ui.ActorPartnerGroup;
	
	import flash.display.DisplayObject;
	import flash.display.DisplayObjectContainer;
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.filters.GlowFilter;
	import flash.text.TextField;
	
	import newx.BaseObject;
	import newx.com.config.StaticIni;
	import newx.com.control.NxClip;
	import newx.com.control.button.NxButton;
	import newx.com.control.comboBox.NxComboBoxEvent;
	import newx.com.control.list.NxListEvent;
	import newx.com.control.text.NxLabel;
	import newx.com.control.window.NxWindowEvent;
	import newx.com.loader.StreamDataLoader;
	import newx.utils.MemoryOptimise;

	/**
	 *自己人物属性
	 * @author yanghr
	 * 
	 */	
	public class MyPropertyLogic 
	{
		private var _eqCellArr:Vector.<NxClip>;
		private var _blind:BindManage;
		private var _model:ModelLocator;
		private var _role:RoleVo;
		private var _tip:TipsMainLogic;
		private var _maxLife:int;
		private var _nowLife:int;
		private var _skill:int;
		private var _gang:int=-1;
		private var _outWork:int	=	-1;
		private var _staWork:int	=	-1;
		private var _interWork:int	=	-1;
		private var _lvl:String	=	" ";
		private var _reputation:int	=	-1;
		private var _figthCount:int	=	-1;
		private var _interAdd:Number=0;
		private var _outAdd:Number=0;
		private var _staAdd:Number=0;
		private var _name:String;
		private var _maxExp:Number;
		private var _exp:Number;
		
		private var _isBind:Boolean;
		
		//阵法相关
		private  var _tabArr:Array=[];
		
		private var _text:TextField	=	new TextField;
		private var _rollUp:MovieClip
		private var _actorGroup:ActorPartnerGroup;
		
		/**
		 *绑定伙伴 
		 * 
		 */
		private var _bindLevelFlag:int=-1;
		private var _dataArr:Array
		private var _blindFlagArr:Array
		private var _blindpropertyArr:Array
		private var _bFlag:int;
		private var _bindClotheModel:int	=	-1;
		private var _bindModel:int	= -1;
		private var _kungfuItem:KungfuItem;
		private var _clotheModel:int;
		
		private var _initBeforeShow:Boolean=false;
		private var _initAlready:Boolean=false;
		/**
		 *装备绑定标记 
		 */		
		private var _bindEquipIndex:int=-1;
		
		private var _bindKungfu:int=-1;
		
		private var _bindXisui:int = -1;
		/**
		 *装备绑定 
		 */		
		private var _eqObjViewflag:Number;
		
		private var _kungfuArr:Array	=	[];
		
		private var _lvlObj:Object;
		/**
		 *装备数量 
		 */		
		private const MAX_EQ:int = 8;
		/**
		 *属性名 
		 */		
		private const DATAOBJ:String="dataobj";
		private const INDEX:String="index";
		private const EQUIP:String="item";
		private const TXT:String="titleTxt2";
		private const LVL:String="infoTxt5";
		private const BIND:String="bind";
		
		private const CONFIGID:String="ConfigID";
		private const BIND_LEVEL:String="bind_level";
			
		private const BATTLE_LAB:String=StaticIni.getSwfLangStr("UIString_1000189");
		
		private var _doubleClickManager	: 	DoubleClickManager;
		
		private var _ui:ActorPropertyUI;
		private static var _self:MyPropertyLogic;

		//存放遮罩的数组
		private var _veilArr:Array=[];
		
		private var _petTipItem:PetTipItem;
		
		/**洗髓数据**/
		private var xisuiArr:Array;
		/**洗髓属性名**/
		private var _xisuiProName:Array;
		
		/**
		 *时装状态    0 显示  1隐藏 
		 */		
		private var fashion:int = 0;
		/**FASHION_SHOW 显示    FASHION_VEIL  隐藏**/
		private const FASHION_SHOW:int=0,FASHION_VEIL:int=1;
		// 步 显
		private const SHOW:int=1,VEIL:int=2,OVER_SHOW:int=3,OVER_VEIL:int=4;
		public static function getInstance():MyPropertyLogic
		{
			if(_self==null)
			{
				_self=new MyPropertyLogic();
			}
			return _self
		}
		public function MyPropertyLogic()
		{
			_ui=new ActorPropertyUI(this);
		}
		public function get currentSelectedM():MovieClip
		{
			return _actorGroup.currentMC;
		}
		private function setCurrentM(value:MovieClip):void
		{
			currentSelectedM=value;
		}
		
		private function clickCallBack():void
		{	
			var view:ObjectData		= currentSelectedM["dataobj"];
			var pos:int				= (view == _role) ? -1 : int(view.ObjKey);
			//请求伙伴洗髓信息
			SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_REQUEST__ALL_WASH_VALUE, pos);
		}
			
		
		public function set currentSelectedM(value:MovieClip):void
		{
			if(DetailPropertyLogic.getInstance().ui.created)
			{
				DetailPropertyLogic.getInstance().showProperty(currentSelectedM[DATAOBJ]);
			}
			refreshUI();
			refreshKungfu();
		}
		/**
		 *刷新属性绑定 
		 * 
		 */		
		private function refreshBlind():void
		{
			var obj:ObjectData=_actorGroup.rollArr[_actorGroup.currentIndex]
			if(obj!=null)
			{
				initProperty(obj);
			}
		}
		/**
		 *刷新武学心法图标 
		 * 
		 */		
		private function refreshKungfu():void
		{
			_ui.kungfuMc.visible=_kungfuArr&&_kungfuArr.length;
		}
		/**
		 *向上箭头  鼠标效果 
		 * @param mc
		 * 
		 */		
		private function set rollUp(mc:MovieClip):void
		{
			if(mc)
			{
				mc.gotoAndStop(2);
			}
			if(_rollUp)
			{
				_rollUp.gotoAndStop(1)
			}
			_rollUp=mc;
		}
		public function BeforeShow():void
		{
			_initAlready=true;
			_initBeforeShow=true;
			for each (var i:NxClip in _eqCellArr) 
			{
				(i.content as MovieClip).gotoAndStop(1);
				var nxx:NxClip=i.data.GetProperties(EQUIP);
				nxx.isCache = true;
				if(!nxx.parent && i.content["img01"] != null )
				{
					(i.content["up"] as MovieClip).buttonMode=true;
					i.content["img01"].addChild(nxx);
					(i.content["up"] as MovieClip).gotoAndStop(1)
					i.content["up"].addEventListener(MouseEvent.ROLL_OVER,function(e:Event):void{
						rollUp=	e.currentTarget as MovieClip
					})
					i.content["up"].addEventListener(MouseEvent.ROLL_OUT,function(e:Event):void{
						rollUp=null;
					})
				}
			}
			_actorGroup.BeforeShow();
			addAllListener();
//			if(_actorGroup.currentIndex==0)
//			{
//				var mc:MovieClip=_ui.actorGroup.getItemByIndex(0);
//				mc[TXT].htmlStr=role.getPlayerName()+"等级："+role.getPlayerLevel();
//			refreshList(_role)
//				refreshBlind()
//				refreshUI()
//			}
				refreshUI();
				
				
//			var name 	: String 	= _role.getPlayerName();
//			var nation 	: String	= _role.GetPropertiesEx("GuildName")//StaticIni.getSwfLangStr( "Nation_" + _role.getPlayNation() );
//			ui.windowBG.title = StaticIni.getSwfLangStrVar( "UIString_1000020", [ name,nation, 1 ] );
//			SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_GET_CLONE_PLAYER_CHALLENGE_TOP,new WString(name));
			_initBeforeShow=false;
			
			var id:int = _model.scene.Role.GetProperties("FightPet");
			if(id == 0){
				ui.petMc.visible = false;
			} else {
				ui.petMc.visible = true;
			}
		}
		public function afterhide():void
		{
			_actorGroup.AfterHide();
			removeAllListener();
			ui.kungfuMc["gotoAndStop"](1);
			ui.xisuiMc.filters		= [];
			ui.xisuiMc.buttonMode	= false;
			ui.xisuiMc.removeEventListener(MouseEvent.CLICK, openXisui);
			ui.petMc.filters 		= [];
		}
		public function Init():void
		{
			_petTipItem = new PetTipItem();
			_eqCellArr=new Vector.<NxClip>;
			_blind=BindManage.getInstance();
			_model=ModelLocator.getInstance();
			_role=_model.scene.Role;
			_tip=TipsMainLogic.instance;
			_kungfuItem=new KungfuItem;
			_ui.battleBtn.label=BATTLE_LAB;
			_ui.xisuiMc.visible = false;
			_lvlObj=StaticIni.getIniObj("MyPropertyUI_LVL");
			_actorGroup=new ActorPartnerGroup(ui.actorGroup,setCurrentM,null,clickCallBack);
//			_actorGroup.partnerChangeCallBack=refreshBlind;
			//伙伴列表
//			initPartnerList();
			_doubleClickManager	= DoubleClickManager.getInstance();
			
			_doubleClickManager.addDoubleClick( MyPropertyLogic, singleClick, doubleClick );
			//装备
			for (var i:int	=	1; i <=	MAX_EQ; i++) 
			{
				var targetStr:String="eq"+i;
				var nx:NxClip	=	ui[targetStr];
				var	contentArr:Object	=	StaticIni.getIniObj("ActorPropertyUI"+"_"+targetStr);
				nx.source=contentArr["source"]//"Picturebox_4";
				nx.addEventListener(MouseEvent.ROLL_OVER,rollOver);
				nx.addEventListener(MouseEvent.ROLL_OUT,rollOut);
				nx.addEventListener(MouseEvent.CLICK,clickIt);
				nx.content['up'].visible=false;
				(nx.content as MovieClip).gotoAndStop(1);
//				trace("i.content['up'].visible=",nx.content["up"].visible);
//				trace("MyPropertyLogic.Init()",nx.defaultImage,nx.defaultImage.visible,nx.defaultImage.parent);

				
//				nx.data=
				_eqCellArr.push(nx);
				nx.data.HandleProperties(INDEX,i);
				//物品
				var nxx:NxClip	=	new NxClip;
				nxx.mouseChildren=nxx.mouseEnabled=nx.content['up'].mouseChildren	=	false;
				nx.data.HandleProperties(EQUIP,nxx);

			}
			
			_veilArr =["custSkin_45","custSkin_46","custSkin_47","custSkin_48","custSkin_49"];
//			_model.addEventListener( String(CustomToClientFlag.SERVER_CUSTOMMSG_SEND_CLONE_PLAYER_CHALLENGE_TOP), getTop );
			_model.addEventListener(String(CustomToClientFlag.SERVER_CUSTOMMSG_WASH_ALL_VALUE), openMyProui);
		}
		
		/**
		 * 处理洗髓数据
		 * @param e
		 * 
		 */
		private function openMyProui(e:CustomMsgEvent):void
		{
			_xisuiProName = new Array;
			xisuiArr = new Array;
			if(e.pList.length == 1){
				xisuiArr = new Array;
				ui.xisuiMc.visible = false;
			} else {
				ui.xisuiMc.visible = true;
				var _allList:Array = (e.pList).slice(1, (e.pList).length);
				var proName:String;
				for(var i:int = 0; i < _allList.length; i += 2){
					var obj:Object = new Object;
					proName = _allList[i];
					if(_xisuiProName.indexOf(proName) == -1){
						obj[proName] = [];
						obj[proName] = _allList[i + 1];
						_xisuiProName.push(proName);
						xisuiArr.push(obj);
					} else {
						var index:int = _xisuiProName.indexOf(proName);
						var _value:Number = Number(xisuiArr[index][proName]);
						xisuiArr[index][proName] = _value + Number(_allList[i + 1]);
					}
				}
			}
		}
		
		
		/**
		 *装备Tips 
		 * @param e
		 * 
		 */		
		private function rollOver(e:Event):void
		{
			var nx:NxClip	=	e.target as NxClip;
			var dataobj:ObjectData	=	nx.data.GetProperties(DATAOBJ)
			var item:NxClip	=	e.currentTarget as NxClip;
			(item.content as MovieClip).gotoAndStop(2)
			if(dataobj!=null)
			{
				dataobj.HandlePropertiesEx(EquipItem.CURRENT_LEVEL,lvl);
				TipsMainLogic.instance.showMain(dataobj,false);
				dataobj.DeletePropertiesEx(EquipItem.CURRENT_LEVEL);
			}
			else
			{
				TipsMainLogic.instance.showMain(StaticIni.getSwfLangStr("EquipStr_"+nx.data.GetProperties(INDEX)));
			}
		}
		private function rollOut(e:Event):void
		{
			var nx:NxClip	=	e.target as NxClip;
			(e.currentTarget.content as MovieClip).gotoAndStop(1);
			TipsMainLogic.instance.hide();
		}
		/**
		 *装备格子点击 
		 * @param e
		 * 
		 */		
		private function clickIt(e:MouseEvent):void
		{
			var nx:NxClip	=	e.currentTarget as NxClip;
			var vo:ViewObject=nx.data.GetProperties(DATAOBJ);
			if(vo)
			{//点击升级图标
				if(e.target==nx.content["up"] )
				{
					if(nx.data.GetProperties("date")==null)
					{
						return;
					}
			        ComposeItemLogic.getInstance().UpgradeItem = vo;
					ComposeItemLogic.getInstance().SetItem(nx.data.GetProperties("date") as ViewObject,2,getEquipView(),int(vo.ObjKey));
					return;
				}
				
			}
			if(nx&&nx.data.CheckProperties(DATAOBJ)&&nx.data.GetProperties(DATAOBJ))
			{
				_doubleClickManager.onClick( MyPropertyLogic, e );
			}
		}
		
		private function singleClick(evt : MouseEvent):void
		{
			var nx:NxClip	=	evt.currentTarget as NxClip;
			if(nx ==null) return;
			MenuListManager.clickItem( MyPropertyLogic, nx.data.GetProperties(DATAOBJ) as ViewObject );
		}
		
		private function doubleClick(evt : MouseEvent):void
		{
			var nx:NxClip	=	evt.currentTarget as NxClip;
			demountEquip( nx.data.GetProperties(DATAOBJ) );
		}
		/**
		 *卸下装备 
		 * @param data
		 * 
		 */		
		public function demountEquip(viewobj:ViewObject ):void
		{
			if(!PackLogic.getInstance().ui.created)
			{
				PackLogic.getInstance().ui.showOrHide();
			}
			var	pos:int;
			var viewID:int;
			if(viewobj.GetProperties("ItemType") ==GameDefine.ItemType_PET_EUIP) //宠物装备
			{
				pos	= int(viewobj.ObjKey);
				viewID =PetLoic.getInstance().currPetView;
			}
			else
			{
				pos  =	GameDefine.EQPOS_HASH_MAP[ viewobj.Properties[ "EquipType" ] ];
				viewID =MyPropertyLogic.getInstance().getEquipView()
			}
			
			if( 0 != pos )
			{
				SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_MOVEITEM,
					viewID, pos,View.VIEWPORT_TOOL, 0 );	
				_model.dispatchEvent(new SoundEvent(SoundEvent.EQUIP_DOWN));
			}
		}
		private function grouprollOut(e:Event):void
		{
			var mc:MovieClip=e.currentTarget as MovieClip;
			if(mc.currentFrame!=3)
			{
				mc.gotoAndStop(1)
			}
		}
		private function grouprollOver(e:Event):void
		{
			var mc:MovieClip=e.currentTarget as MovieClip;
			var obj:ObjectData=_actorGroup.rollArr[e.currentTarget[INDEX]];
			var p1:String=obj.GetPropertiesEx("ConfigID")?StaticIni.getSwfLangStr(obj.GetPropertiesEx("ConfigID")):obj.GetPropertiesEx("Name");
			var plist:Array=[p1,obj.GetPropertiesEx(getExpName(mc[INDEX])),obj.GetPropertiesEx(getMaxExpName(mc[INDEX]))];
			_tip.showString(StaticIni.getSwfLangStrVar("UIString_1000037",plist));
			if(mc.currentFrame!=3)
			{
				mc.gotoAndStop(2)
			}
			
		}
		private function getExpName(index:int):String
		{
			if(index!=0)
			{
				return "PartnerExp"
			}
			else
			{
				return ActorPropertyUI.CUR_EXP;
			}
		}
		private function getMaxExpName(index:int):String
		{
			if(index!=0)
			{
				return "PartnerUpgradeExp"
			}
			else
			{
				return ActorPropertyUI.CUR_MAX_EXP;
			}
		}
		public function addAllListener():void
		{
			_isBind=true;
			ui.chengskillBtn.addEventListener(MouseEvent.CLICK,onChangSkill);
			ui.actorGroup.addItemsEvent(MouseEvent.ROLL_OVER,grouprollOver);
			ui.actorGroup.addItemsEvent(MouseEvent.ROLL_OUT,grouprollOut);
			ui.windowBG.addEventListener(MouseEvent.CLICK,btnClickHandle,true);
			ui.skillComb.addEventListener(NxComboBoxEvent.NXCOMBOBOX_CLICK,skillClick);
			ui.skillComb.addEventListener(NxListEvent.ITEM_ROLLOVER,itemRollOver,true);
			ui.windowBG.addEventListener(NxWindowEvent.WINDOW_CLOSE,hidHandle);
			ui.windowBG.addEventListener(MouseEvent.MOUSE_OVER,labelTipsHandle);
			ui.veilBtn.addEventListener(MouseEvent.CLICK,onClick);
			ui.veilBtn.addEventListener(MouseEvent.MOUSE_OVER,onOver);
			ui.veilBtn.addEventListener(MouseEvent.MOUSE_OUT,onOut);
//			ui.windowBG.addEventListener(MouseEvent.MOUSE_OUT,hidTIps);
			if(_bindLevelFlag==-1)
			{
				_bindLevelFlag	=	_blind.BindProp(_model.scene.Role,ActorPropertyUI.LEVEL,this,"myLevel");
			}
			
			if(_bindClotheModel == -1)
			{
				_bindClotheModel	=	_blind.BindProp(_model.scene.Role,"ClotheModel",this,"clotheModel");
			}
			if(_bindModel == -1)
			{
				_bindModel	=	_blind.BindProp(_model.scene.Role,"Model",this,"model");
			}
		}
		private function onClick(e:MouseEvent):void
		{
			var val:int = fashion==0?FASHION_VEIL:FASHION_SHOW
			SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_SET_FASHION_SWITCH,val);
		}
		private function onOver(e:MouseEvent):void
		{
			ui.veilBtn.buttonMode = true;
			if(fashion == FASHION_SHOW)
			{
				ui.veilBtn.gotoAndStop(OVER_VEIL);
			}
			else
			{
				ui.veilBtn.gotoAndStop(OVER_SHOW);
			}
		}
		private function onOut(e:MouseEvent):void
		{
			if(fashion == FASHION_SHOW)
			{
				ui.veilBtn.gotoAndStop(VEIL);
			}
			else
			{
				ui.veilBtn.gotoAndStop(SHOW);
			}
		}
		private function onChangSkill(e:MouseEvent):void
		{
			SpecialKungFuUI.getInstance().show();
		}
		private function itemRollOver(e:NxListEvent):void
		{
			var str:String	=	StaticIni.getSwfLangStr("SkillDes_"+e.itemData.data);//+skillId;
			_tip.showMain(str);
		}
		private function hidTIps(e:Event):void
		{
			_tip.hide();
		}
		public function removeAllListener():void
		{
			_isBind=false;
			ui.chengskillBtn.removeEventListener(MouseEvent.CLICK,onChangSkill);
			ui.actorGroup.removeItemsEvent(MouseEvent.ROLL_OVER,grouprollOver)
			ui.actorGroup.removeItemsEvent(MouseEvent.ROLL_OUT,grouprollOut);
			ui.windowBG.removeEventListener(MouseEvent.CLICK,btnClickHandle,true)
			ui.skillComb.removeEventListener(NxComboBoxEvent.NXCOMBOBOX_CLICK,skillClick);
			ui.skillComb.removeEventListener(NxListEvent.ITEM_ROLLOVER,itemRollOver,true);
			ui.windowBG.removeEventListener(NxWindowEvent.WINDOW_CLOSE,hidHandle)
			ui.windowBG.removeEventListener(MouseEvent.MOUSE_OVER,labelTipsHandle);
			ui.veilBtn.addEventListener(MouseEvent.CLICK,onClick);
			ui.veilBtn.addEventListener(MouseEvent.MOUSE_OVER,onOver);
			ui.veilBtn.addEventListener(MouseEvent.MOUSE_OUT,onOut);
//			ui.windowBG.removeEventListener(MouseEvent.MOUSE_OUT,hidTIps);
			unblindAllProperty();
			if(_bindClotheModel != -1)
				_bindClotheModel	=	_blind.UnbindProp(_model.scene.Role,"ClotheModel",_bindClotheModel);
			if(_bindModel != -1)
				_bindModel	=	_blind.UnbindProp(_model.scene.Role,"Model",_bindModel);

		}
		private function hidHandle(e:Event):void
		{
			ui.hide();
		}
		
		/**
		 *技能combox回调 
		 * @param e
		 * 
		 */		
		private function skillClick(e:NxComboBoxEvent):void
		{
			var configid:int;
			configid=e.item.data ;
//			ui.skillComb.setSelected(e.item.index)
			SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_SET_DEFAULT_SKILL,configid);
		}
		/**
		 *	Tip回调 
		 * @param e
		 * 
		 */		
		private function labelTipsHandle(e:Event):void
		{
			var  str:String="";
			var obj:ObjectData=_actorGroup.rollArr[_actorGroup.currentIndex];
			var target:DisplayObject=e.target as DisplayObject
			var plist:Array;
			var glow:GlowFilter		= new GlowFilter();
			glow.color 				= 0xFFFFFF;
			switch(e.target)
			{
				//主角图像
				case ui.actorVisual:
				{
					str	=	"UIString_1000035"
					break;
				}
				case ui.developBtn:
				{
					break;
				}
				case ui.gangTxT:
				{
					break;
				}
				case ui.interWorkTxT:
				{
					str	=	"UIString_1000033"
					break;
				}
				case ui.outWorkTxT:
				{
					str	=	"UIString_1000032"
					break;
				}
				case ui.sta_lab:
				{
					str	=	"UIString_1000034"
					break;
				}
				case ui.lifeTxT:
				{
					break
				}
				case ui.lvlTxT:
				{
					break;
				}
				case ui.medicineBtn:
				{
					break;
				}
				
				case ui.veilBtn:
				{
					if(fashion == FASHION_SHOW)
					{
						str ="UIString_1000720"
					}
					else
					{
						str ="UIString_1000719";
					}
					break;
				}
				case ui.nameTxT:
				{
					break;	
				}
				case ui.partnerBtn:
				{
					break;
				}
				case ui.reputationTxT:
				{
					str	=	"UIString_1000614";
					plist=getPartnerTipsStr();
					break;
				}
				case ui.fightCountTxT :
				{
					str	=	"UIString_1000735";
					plist = [ _figthCount,int( _model.scene.Role.GetProperties("FightPetPower"))] ; 
					break 
				}
				case ui.kungfuMc:
				{
					var arr:Array=_kungfuArr;
					if(!(arr&&arr.length))return ;
					arr.sort(
						function compare(v1:BaseObject,v2:BaseObject):int
						{
							if(v1.GetProperties("KungFuQuality")==v2.GetProperties("KungFuQuality"))
							{
								return v2.GetProperties("KungFuLevel")-v1.GetProperties("KungFuLevel")
							}
							else
							{
								return v2.GetProperties("KungFuQuality")-v1.GetProperties("KungFuQuality")
							}
						}
					)
					for each (var val:ViewObject in arr) 
					{
						_kungfuItem.data=(val as ViewObject).Properties;
						str+=_kungfuItem.getLittleStr()+"\n";
					}
					ui.kungfuMc["gotoAndStop"](2);
					if(str)
						_tip.showWideString(str);
					return ;
//					str=str.slice(0,str.length-1);
					break;
				}
				case ui.petMc:
				{
					ui.petMc.filters = [glow];
					var id:int = _model.scene.Role.GetProperties("FightPet");
					if(id == 0)return;
//					ui.petMc["gotoAndStop"](2);
					var _arr:Array = new Array();
					_arr.push(id);
					_arr.push(_model.scene.Role.GetProperties("FightPetName"));
					_arr.push(_model.scene.Role.GetProperties("FightPetGrade"));
					_arr.push(_model.scene.Role.GetProperties("FightPetLevel"));
					_arr.push(_model.scene.Role.GetProperties("FightPetPropLevel"));
					_arr.push(_model.scene.Role.GetProperties("FightPetPower"));
					str = _petTipItem.getPetTips(_arr);
					_tip.showString(str);
					break;
				}
				case ui.xisuiMc:
				{
					ui.xisuiMc.filters		= [glow];
					ui.xisuiMc.buttonMode	= true;
					ui.xisuiMc.addEventListener(MouseEvent.CLICK, openXisui);
					var precent:Object		=StaticIni.getIniObj("PercentMap");
					str += StaticIni.getSwfLangStr("RandomPropertyTips_32") + "\n";
					for(var i:int = 0; i < xisuiArr.length; i ++){
						var _xisuiobj:Object = xisuiArr[i];
						for(var z:String in _xisuiobj){
							var value:* = (precent.hasOwnProperty(z)) ? Number(_xisuiobj[z]).toFixed(2) : int(_xisuiobj[z]);
							var _addstr:String = (i == xisuiArr.length - 1) ? "" : "\n";
							var soucre:String = StaticIni.getSwfLangStrVar("Item_" + (z), [value]) + _addstr;
							str += _tip.getColorHtml(soucre , "ff8000");
						}
					}
					_tip.showString(str);
					break;
				}
				default:
				{
					ui.kungfuMc["gotoAndStop"](1);
					ui.xisuiMc.filters		= [];
					ui.xisuiMc.buttonMode	= false;
					ui.xisuiMc.removeEventListener(MouseEvent.CLICK, openXisui);
					ui.petMc.filters 		= [];
//					ui.petMc["gotoAndStop"](1);
					if(ui.expBar.contains(target)||ui.expTxT.contains(target))
					{
						var exp:int=int(obj.GetPropertiesEx(getExpName(_actorGroup.currentIndex)))*100;
						var mxexp:int=int(obj.GetPropertiesEx(getMaxExpName(_actorGroup.currentIndex)))
						//GameDefine.GET_MAXHP(obj.GetPropertiesEx("Sta"))
						if(maxExp)
						{
							_tip.showString(
								(Math.min(exp/mxexp,100)).toFixed(2)+"%"
							)
						}
						else
						{
							_tip.showString(
								"0%"
							)
						}
							return;
					}
					else if(ui.skillComb.contains(target)||ui.skill_lab.contains(target))
					{
						str	=	"SkillDes_"+obj.GetPropertiesEx("DefaultUltraSkill")//+skillId
					}
					else if(ui.detailLab.contains(target))
					{
						str	=	"UIString_1000035"
					}
					else if(ui.actorGroup.contains(target))
					{
//						grouprollOver(e);
						return ;
					}
					else if(_ui.battleBtn.contains(target))
					{
						str	=	_ui.battleBtn.data.GetProperties("tips")
					}
					else if(_eqCellArr.some(eachItem))
					{
						return ;
					}
				}
			}
			if(str)
				_tip.showString(StaticIni.getSwfLangStrVar(str,plist))
			else
				_tip.hide();
			function eachItem(item:NxClip,index:int,arr:*):Boolean{
				return item.contains(e.target as DisplayObject)
			}
		}
		
		private function openXisui(e:MouseEvent):void
		{
			WashMarrowLogic.getInstance().ui.showOrHide();
		}
		
		/**
		 *鼠标移到声望的Tips文本参数 
		 * @return 
		 * 
		 */
		private function getPartnerTipsStr():Array
		{
			var arr :　Array = [];
			var reputationLevel : int = _role.GetPropertiesEx(ActorPropertyUI.PARTNER_INVITE);
			var commendStr : String = "";
			var nextPartner : String = "";
			var PartnerGroup : Array;
			var nextLevelPartnerGroup : Array;
			var commendPartnerGroup : Array;
			if(reputationLevel<=10)
			{
				PartnerGroup = PartnerRequestNewLogic.getInstance().getPartnerByLevel(reputationLevel).partnerVecor as Array;
				if(reputationLevel<=9)
				{
					commendPartnerGroup = PartnerRequestNewLogic.getInstance().getPartnerByLevel(reputationLevel+1).partnerVecor as Array;
					if(reputationLevel<=8)
					{
						nextLevelPartnerGroup = PartnerRequestNewLogic.getInstance().getPartnerByLevel(reputationLevel+2).partnerVecor as Array;
					}
				}
			}
			if(PartnerGroup)
			{
				for(var k:int = 0;k<PartnerGroup.length;k++)
				{
					var partner : Object = PartnerGroup[k];
					var configid : int = partner.ConfigID;
					var Recommend : int = partner.NeedRecommend;
					if(Recommend == 1)
					{
						commendStr += StaticIni.getSwfLangStr(configid.toString())+","+GameDefine.PART_PROFTYPE(partner.ProfType)+"(<font color ='#1eff00'>"+StaticIni.getSwfLangStr("UIString_1000023")+"</font>)<br>";
					}
				}
			}
			if(commendPartnerGroup)
			{
				for(var i:int = 0;i<commendPartnerGroup.length;i++)
				{
					var partnerObj : Object = commendPartnerGroup[i];
					var configID : int = partnerObj.ConfigID;
					var needRecommend : int = partnerObj.NeedRecommend;
					if(needRecommend == 1)
					{
						commendStr += StaticIni.getSwfLangStr(configID.toString())+","+GameDefine.PART_PROFTYPE(partnerObj.ProfType)+"(<font color ='#1eff00'>"+StaticIni.getSwfLangStr("UIString_1000023")+"</font>)<br>";
					}
				}
				if(commendStr == "")
				{
					commendStr = StaticIni.getSwfLangStr("Common_Null");
				}
				else
				{
					commendStr = commendStr.slice(0,commendStr.length-4);
				}
			}
			else
			{
				commendStr = StaticIni.getSwfLangStr("Common_Null");
			}
			
			if(nextLevelPartnerGroup)
			{
				for(var j:int = 0;j<nextLevelPartnerGroup.length;j++)
				{
					var _partnerObj : Object = nextLevelPartnerGroup[j];
					var _configID : int = _partnerObj.ConfigID;
					var _needRecommend : int = _partnerObj.NeedRecommend;
					if(_needRecommend == 1)
					{
						nextPartner += StaticIni.getSwfLangStr(_configID.toString())+","+GameDefine.PART_PROFTYPE(_partnerObj.ProfType)+"(<font color ='#1eff00'>"+StaticIni.getSwfLangStr("UIString_1000023")+"</font>)<br>";
					}
					else
					{
						nextPartner += StaticIni.getSwfLangStr(_configID.toString())+","+GameDefine.PART_PROFTYPE(_partnerObj.ProfType)+"<br>";
					}
				}
				if(nextPartner == "")
				{
					nextPartner = StaticIni.getSwfLangStr("Common_Null");
				}
			}
			else
			{
				nextPartner = StaticIni.getSwfLangStr("Common_Null");
			}
			arr.push(reputationLevel,commendStr,nextPartner);
			return arr;
		}
		/**
		 *按钮回调 
		 * @param e
		 * 
		 */		
		private function btnClickHandle(e:Event):void
		{
			if(!(e.target is MovieClip || e.target is NxClip || e.target is NxButton || e.target is NxLabel))
			{//不知为什么会进两次回调.先这样处理以后发现问题再改
				return;
			}
				
			if(ui.actorVisual.contains(e.target	 as DisplayObject)||e.target	==	ui.detailLab)
			{
				DetailPropertyLogic.getInstance().ui.showOrHide();
				DetailPropertyLogic.getInstance().showProperty(currentSelectedM[DATAOBJ]);
				
			}
			else if(e.target	==	ui.medicineBtn)
			{
				IntensifyUI.getInstance().showOrHide();
			}
			else if(e.target	==	ui.partnerBtn)
			{
				if(_actorGroup.currentIndex==0)//主角
				{
//					ui.partnerBtn.label="伙伴"
//					PartnerInviteLogic.getInstance().ui.showOrHide();
					PartnerRequestNewUI.getInstance().showOrHide();
				}
				else//伙伴
				{
//					ui.partnerBtn.label=""
//					离队
					var configID:int=_actorGroup.currentData.GetPropertiesEx("ConfigID");
					retirePartner(configID);
				}
			}
			else if(ui.battleBtn.contains(e.target as DisplayObject)&&ui.battleBtn.enabled)//传承
			{
				if(ui.battleBtn.label==BATTLE_LAB)
					EmbattleLogic.getInstance().ui.showOrHide();
				else
					ImpartPropertyLogic.getInstance().showWithPartner(_actorGroup.rollArr[_actorGroup.currentIndex])
			}
			else if( ui.kungfuMc.contains(e.target as DisplayObject))
			{
				KungfuPackLogic.getInstance().ui.showOrHide();
			}
				
		}
		/**
		 *离队伙伴 
		 * @param configid
		 * 
		 */		
		public function retirePartner(configid:int):void
		{
			SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_RETIRE_PARTNER,configid)
		}
		private function refreshUI():void
		{
			refreshBtn();
			removeAllVeil();
			clearAllEq()
			refreshSkillComb()
			refreshBlind();
			refreshKungfu();
		}
		/**
		 *刷新按钮显示 
		 * 
		 */		
		private function refreshBtn():void
		{
			ui.partnerBtn.label	=	StaticIni.getSwfLangStr(_actorGroup.currentIndex?"UIString_1000008":"UIString_1000009");
			var view:ObjectData=_actorGroup.rollArr[_actorGroup.currentIndex];
			if(view is RoleVo)
			{
				_ui.battleBtn.label=BATTLE_LAB;
				_ui.battleBtn.data.HandleProperties("tips","")
				_ui.battleBtn.enabled=true;
				updateFashionVisible();
			}
			else
			{
				_ui.battleBtn.label=StaticIni.getSwfLangStr("ImportStr_18");
				var configid1:int=ImpartPropertyLogic.getInstance().viewInherit(view);
				var configid2:int=ImpartPropertyLogic.getInstance().viewBeInherit(view);
				var str1:String=StaticIni.getSwfLangStrVar("ImportStr_20",[StaticIni.getSwfLangStr(configid2+"")])//已被xxx灌顶
				var str2:String=StaticIni.getSwfLangStrVar("ImportStr_21",[StaticIni.getSwfLangStr(configid1+"")])//已灌顶给xxx
				if(configid1&&configid2)//已灌顶给XXX已被xxx灌顶，此时按钮变灰
				{
					_ui.battleBtn.data.HandleProperties("tips",str1+"\n"+str2)
				}
				else	if(configid2)//已被xxx灌顶
				{
					_ui.battleBtn.data.HandleProperties("tips",str1)
				}
				else if(configid1)//已灌顶给xxx
				{
					_ui.battleBtn.data.HandleProperties("tips",str2)
				}
				else
				{
					_ui.battleBtn.data.HandleProperties("tips",StaticIni.getSwfLangStr("ImportStr_19"))
				}
				_ui.battleBtn.enabled=	_ui.battleBtn.buttonMode=!configid1;
				_ui.battleBtn.mouseEnabled=true;
				_ui.veilBtn.visible = false;
			}
			refreshVisible();
		}
		/**
		 *刷新技能下拉菜单 
		 * 
		 */		
		private function refreshSkillComb():void
		{
			ui.skillComb.visible	=	false//!_actorGroup.currentIndex&&skillArray.length>1;  
				return;//删除切换技能
			var skillArray:Array=SkillLogic.getInstance().getStudyedSkill();
			ui.skill_lab.visible	=	!ui.skillComb.visible;
			var obj:Object=ui.skillComb.getSelecedItem();
			var currentSelect:int;
			if(obj)
				currentSelect=skillArray.indexOf(obj.data)
			else
				currentSelect=-1;
			ui.skillComb.clear();
//			skillArray.unshift(GameDefine.GET_FIRST_SKILL(_role.GetPropertiesEx(ActorPropertyUI.GANG)));
			skillArray.forEach(eachItem);
			ui.skillComb.showCount=skillArray.length;
			ui.skillComb.data.HandleProperties(DATAOBJ,skillArray);
//			trace("MyPropertyLogic.refreshSkillComb()",_role.GetPropertiesEx("DefaultUltraSkill"),"**",skillArray);
			if(currentSelect>-1)
				ui.skillComb.setSelected(currentSelect);
			function eachItem(item:int,index:int,arr:Array):void
			{
				_text.htmlText=StaticIni.getSwfLangStr(item+"")
//				trace("MyPropertyLogic.eachItem(item, index, arr)",_text.text);
				ui.skillComb.addItem({label:_text.text,data:item});
			}
		
		}
		/**
		 *移除所有装备 
		 * 
		 */		
		private function clearAllEq():void
		{
			for (var i:int = 0; i < _eqCellArr.length; i++) 
			{
				clearEq(i);
			}
		}
		/**
		 *移除装备 
		 * @param index
		 * 
		 */		
		private function clearEq(index:int):void
		{
			var nx:NxClip=_eqCellArr[index];
			var datait:BaseObject=nx.data;
			datait.HandleProperties(DATAOBJ,null);
			(nx.data.GetProperties(EQUIP) as NxClip).clear();
			nx.content["up"].visible=false;
			(nx.data.GetProperties(EQUIP) as NxClip).source=null;
		}
		public function set photo(value:String):void 
		{
//			var url : String  = StageInfo.npcResPath + value + "_ani_0.swf";
			//			if( photoMc != null && url == actorVisual.name)
			//			{
			//				return;
			//			}
			var roleSkinIndex:int	=	0;
			var url:String	=	getUrl()
			url	=	ResPath.ACTORS + url;
			_ui.actorVisual.source =url
//			roleModel	=	ResPath.ACTORS + roleModel + value + ".swf";
//			ResManager.loadResNoSave(url, url, onPhotoLoad,[url]);
			function getUrl():String
			{
				var head:String;
				var tails:String;
				if(_actorGroup.currentIndex!=0)
				{
					head	=	"npc_";
					tails	=	".swf";
					setParentEuqePos();
				}
				else
				{
					setRoleEuqePos();
					roleSkinIndex	=	ModelLocator.getInstance().scene.Role.GetPropertiesEx("ClotheModel");
					roleSkinIndex	=	roleSkinIndex  == 0 ? 1 : roleSkinIndex;
					head	=	"role_";
					tails	=	"_"+roleSkinIndex+".swf";					
				}
				return head+value+tails;
			}
			
		}
		
		private function setRoleEuqePos():void
		{
			_ui.eq7.visible = _ui.eq8.visible = true;
			_ui.eq1.y =_ui.eq4.y = 65;
			_ui.eq2.y =_ui.eq5.y = 114;
			_ui.eq3.y =_ui.eq6.y = 164;
			
		}
		private function setParentEuqePos():void
		{
			_ui.eq7.visible = _ui.eq8.visible = false;
			_ui.eq1.y =_ui.eq4.y = 77;
			_ui.eq2.y =_ui.eq5.y = 139;
			_ui.eq3.y =_ui.eq6.y = 200;
		}
		private function clearPhoto():void
		{
			MemoryOptimise.stopMovie(ui.photoMc);
			ui.actorVisual.clear();
			ui.photoMc = null;
		}
		
		/**
		 *最大生命 
		 * @return 
		 * 
		 */		
		public function get maxLife():int 
		{ 
			return _maxLife; 
		}
		
		public function set maxLife(value:int):void
		{
			var data:BaseObject=currentSelectedM[DATAOBJ];
			DetailPropertyLogic.getInstance().setData(data);
			value=int(DetailPropertyLogic.getInstance().maxlife)//GameDefine.GET_MAXHP(value)
			if (_maxLife == value)
				return;
			_maxLife = value;
			refreshLife();
		}
		
		
		/**
		 *当前生命 
		 * @return 
		 * 
		 */		
		public function get nowLife():int 
		{ 
			return _nowLife; 
		}
		
		
		public function set nowLife(value:int):void
		{
			if (_nowLife == value)
				return;
			_nowLife = value;
			refreshLife()
		}
		/**
		 *人物模型变换 
		 */		
		public function set clotheModel(val:int):void
		{
			_clotheModel	=	val;
			if(_actorGroup.currentIndex==0)
			photo	=	ModelLocator.getInstance().scene.Role.GetPropertiesEx("Model");
		}
		public function set model(val:int):void
		{
			if(_actorGroup.currentIndex==0)
				photo	=	val.toString();
		}
		/**
		 *生命值刷新 
		 * 
		 */		
		private function refreshLife():void
		{
			ui.lifeTxT.htmlStrByBorder=StaticIni.getSwfLangStrVar("UIString_1000010",[/*nowLife+"/"+*/maxLife]);
		}
		
		public function get skill():int 
		{ 
			return _skill; 
		}
		
		public function set skill(value:int):void
		{
//			if (_skill == value)
//				return;
			_skill = value;
			var dataArr:Array=ui.skillComb.data.GetProperties(DATAOBJ);
			var index:int=dataArr.indexOf(value+"")
//			trace("MyPropertyLogic.skill(value)",index);
			ui.skillComb.setSelected(index);
			//				="招式："+value;
		}
		
		public function get gang():int 
		{ 
			return _gang;
		}
		
		public function set gang(value:int):void
		{
//			if (_gang == value)
//				return;
			_gang = value;
			if(_actorGroup.currentData is RoleVo)
			{
				ui.gangTxT.htmlStrByBorder=StaticIni.getSwfLangStrVar("UIString_1000567",[GameDefine.PART_GANG(value)]);
			}
			else
			{
				ui.gangTxT.htmlStrByBorder=StaticIni.getSwfLangStrVar("UIString_1000011",[GameDefine.PART_PROFTYPE(value)]);
			}
		}
		
		public function get outWork():int 
		{ 
			return _outWork; 
		}
		
		public function set outWork(value:int):void
		{
			if (_outWork == value)
				return;
			_outWork = int(value);
			refreshOut()
		}
		public function get outAdd():Number 
		{ 
			return _outAdd; 
		}
		
		public function set outAdd(value:Number):void
		{
			if (_outAdd == value)
				return;
			_outAdd = value;
			refreshOut()
		}
		private function refreshOut():void
		{
			ui.outWorkTxT.htmlStrByBorder=StaticIni.getSwfLangStrVar("UIString_1000012",[int(outAdd+outWork)]);
		}
		
		public function get interWork():int 
		{
			return _interWork; 
		}
		
		public function set interWork(value:int):void
		{
			if (_interWork == value)
				return;
			_interWork = value;
			refreshInter()
		}
		public function get interAdd():Number 
		{ 
			return _interAdd; 
		}
		
		public function set interAdd(value:Number):void
		{
			if (_interAdd == value)
				return;
			_interAdd = value;
			refreshInter()
		}
		
		private function refreshInter():void
		{
			ui.interWorkTxT.htmlStrByBorder=StaticIni.getSwfLangStrVar("UIString_1000013",[int(interAdd+interWork)]);
		}
		/**
		 *体魄 
		 * @return 
		 * 
		 */		
		public function get staWork():int 
		{
			return _staWork; 
		}
		
		public function set staWork(value:int):void
		{
			if (_staWork == value)
				return;
			_staWork = int(value);
			refreshSta()
			
		}

		public function get staAdd():Number 
		{ 
			return _staAdd; 
		}
		
		public function set staAdd(value:Number):void
		{
			if (_staAdd == value)
				return;
			_staAdd = value;
			refreshSta()
		}
		private function refreshSta():void
		{
			ui.sta_lab.htmlStrByBorder=StaticIni.getSwfLangStrVar("UIString_1000014",[int(staAdd+staWork)]);
		}
		/**
		 *等级 
		 * @return 
		 * 
		 */		
		public function get lvl():String 
		{
			return _lvl; 
		}
		
		public function set lvl(value:String):void
		{
			if (_lvl == value)
				return;
			_lvl = value;
			ui.lvlTxT.htmlStrByBorder=StaticIni.getSwfLangStrVar("UIString_1000015",[value]);
		}
	
		public function get maxExp():Number 
		{ 
			return _maxExp; 
		}
		
		public function set maxExp(value:Number):void
		{
			if (_maxExp == value)
				return;
			_maxExp = value;
			refreshExpBar()
		}
		
		public function get exp():Number 
		{ 
			return _exp; 
		}
		
		public function set exp(value:Number):void
		{
			if (_exp == value)
				return;
			_exp = value;
			refreshExpBar()

		}
		private function refreshExpBar():void
		{
			if(_maxExp)
			{
				(ui.expBar["loadingLine"] as MovieClip).width=Math.min(_exp/_maxExp,1)*(ui.expBar["loadingLineBack"].width-11);
			}
			else
			{
				(ui.expBar["loadingLine"] as MovieClip).width=0;
			}
			ui.expTxT.htmlStrByBorder=StaticIni.getSwfLangStrVar("UIString_1000016",[_exp+"/"+_maxExp]);
		}
		
		/**
		 *声望 
		 * @return 
		 * 
		 */		
		public function get reputation():int 
		{ 
			return _reputation;
		}
		
		public function set reputation(value:int):void
		{
			if (_reputation == value)
				return;
			_reputation = value;
			ui.reputationTxT.htmlStrByBorder=StaticIni.getSwfLangStrVar("UIString_1000017",[value]);
		}
		public function set skillid(id:int):void
		{
			 var _skillName:String="";
			_skillName=StaticIni.getSwfLangStr(id+"");
//			_text.htmlText=_skillName
//			ui.skillComb.clear();
//			ui.skillComb.addItem({label:_text.text,data:id});
			ui.skill_lab.htmlStrByBorder=_skillName;
		}
		
		/**
		 *战斗力 
		 * @return 
		 * 
		 */		
		public function get figthCount():int 
		{ 
			return _figthCount; 
		}
		
		public function set figthCount(value:int):void
		{
//			if (_figthCount == value)
//				return;
			_figthCount = value;
			ui.fightCountTxT.htmlStrByBorder=StaticIni.getSwfLangStrVar("UIString_1000018",[value +int(_model.scene.Role.GetProperties("FightPetPower"))]);
		}
		/**
		 *人物名 
		 * @return 
		 * 
		 */		
		public function get actorName():String 
		{ 
			return _name;
		}
		
		public function set actorName(value:String):void
		{
			if (_name == value)
				return;
			_name = value;
			ui.nameTxT.htmlStrByBorder="<b>"+_tip.getColorHtml(value,"ffdf8a")+"</b>";
		}
		public function set configIId(ii:int):void
		{
			actorName	=	StaticIni.getSwfLangStr(ii+"")+"";
		}
		public function get ui():ActorPropertyUI
		{
			return _ui as ActorPropertyUI;
		}
		private function initBlind():void
		{
			_bFlag=0;
			_dataArr=[];
			_blindFlagArr=[];
			_blindpropertyArr=[];
		}
		/**
		 *绑定对象
		 * 只有在界面初始化 和viewGroup被选择时 调用 
		 * @param view
		 * 
		 */		
		private function initProperty(view:ObjectData):void
		{
			unblindAllProperty()
			//初始化绑定
			initBlind();
			//绑定属性
			blindProperty( ActorPropertyUI.TOTAL_FIGHT_POWER, "figthCount",_role );
//			blindProperty( ActorPropertyUI.MODEL, "photo",view );
			blindProperty( ActorPropertyUI.LEVEL, "lvl" ,view);
			blindProperty( ActorPropertyUI.HP, "nowLife",view );
			blindProperty(ActorPropertyUI.MAX_HP,"maxLife",view);
			blindProperty(ActorPropertyUI.MAX_HP_ADD,"maxLife",view);
			blindProperty(ActorPropertyUI.MAX_HP_BONUS,"maxLife",view);
			blindProperty(ActorPropertyUI.MAX_HP_BONUS_ADD,"maxLife",view);
			blindProperty(ActorPropertyUI.MAX_HP_MUL,"maxLife",view);
			blindProperty(ActorPropertyUI.MAX_HP_MUL_ADD,"maxLife",view);
			if(view==_role)
				blindProperty(ActorPropertyUI.NAME,"actorName",view)
			else
				blindProperty(ActorPropertyUI.CONFIG_ID,"configIId",view);
			blindProperty(ActorPropertyUI.SKILL_ID,"skillid",view)
			blindProperty(ActorPropertyUI.REPUTATION,"reputation",view);
			blindProperty(getExpName(_actorGroup.currentIndex),"exp",view);
			blindProperty(getMaxExpName(_actorGroup.currentIndex),"maxExp",view);
			blindProperty(ActorPropertyUI.INTER_WORK,"interWork",view);
			blindProperty(ActorPropertyUI.INTER_ADD,"interAdd",view);
			blindProperty(ActorPropertyUI.OUT_WORK,"outWork",view);
			blindProperty(ActorPropertyUI.OUT_ADD,"outAdd",view)
			blindProperty(ActorPropertyUI.STA_WORK,"staWork",view);
			blindProperty(ActorPropertyUI.STA_ADD,"staAdd",view);
			blindProperty(ActorPropertyUI.GANG,"gang",view);
//			blindProperty(ActorPropertyUI.SKILL_ID,"skill",_role);
			
			IntensifyLogic.getInstance().updataByBuddy(view);
			//绑定装备
			_bindEquipIndex		=	_blind.BindView(_model.scene,getEquipView(),onAddHandle,onRemoveHandle,null,updateFunc);
			_bindKungfu		=	_blind.BindView(_model.scene,getKungfuViewID(),OnAddKungfu,OnRemoveKungfu);
			//人物
			photo=view.GetPropertiesEx(ActorPropertyUI.MODEL);

		}
		private function OnAddKungfu(PropertiesName:String,PropertiesValue:ViewObject,data:*):void
		{
			if(_kungfuArr.indexOf(PropertiesValue)==-1)
				_kungfuArr.push(PropertiesValue)
			refreshKungfu();
		}
		private function OnRemoveKungfu(PropertiesName:String,PropertiesValue:ViewObject,data:*):void
		{
			var index:int=_kungfuArr.indexOf(PropertiesValue)
			if(index!=-1)
				_kungfuArr.splice(index,1);
			refreshKungfu();
		}
		
		/**
		 *根据id（ConfigID）取伙伴表结构
		 * @param id	0：ConfigID   
		 * 				1：装备
		 * 				2：技能
		 * 				3：BUFF 
		 * 				4.功法
		 * 				elt.
		 * @return 
		 * @author yanghr
		 */		
		public function getPartnerViewsById(id:int=0):Array
		{
			var re:Record=_model.scene.GetPropertiesEx("PartnerViewIDRec");
			for each (var i:Array in re.recArr) 
			{
				if(i[0]==id)
					return i;
			}
//			trace("Error~MyPropertyLogic.getPartnerViewsById()PartnerViewIDRec表不存在吧？", re.recArr);
			return null;
		}
		private function blindProperty(source:String,target:String,dataObj:ObjectData=null):void
		{
			if(dataObj==null)
			{
				dataObj=_role;
			}
			if(!dataObj.CheckProperties(source))
			{
//				trace("MyPropertyLogic.blindProperty,dataObj没有这个属性：",source,dataObj.GetPropertiesEx("Name"));
				if(_role.CheckProperties(source))
				{
					blindProperty(source,target,_role)
				}
				else
				{
//					trace("MyPropertyLogic.blindProperty,_role没有这个属性：",source);
				}
				return ;
			}
			_blindFlagArr[_bFlag]=_blind.BindProp(dataObj,source,this,target);
			_blindpropertyArr[_bFlag]=source;
			_dataArr[_bFlag]=dataObj;
			_bFlag++;
		}
		private function unblindAllProperty():void
		{
			if(!_blindpropertyArr||!_blindpropertyArr.length)
				return ;
			for (var i:int = 0; i < _blindpropertyArr.length; i++) 
			{
				_blindFlagArr[i]=_blind.UnbindProp(_dataArr[i],_blindpropertyArr[i],_blindFlagArr[i])
			}
			_bindEquipIndex		=	_blind.UnbindView(_eqObjViewflag,_bindEquipIndex);
			_bindKungfu		=	_blind.UnbindView(_eqObjViewflag,_bindKungfu);
			_bindXisui		=	_blind.UnbindRecord("WashPulpBaseRec", _bindXisui);
			_kungfuArr=[];
		}
		/**
		 *添加遮罩 
		 * 
		 */		
		private function addVeil(ViewObj:ViewObject,mc:NxClip):void
		{
			var color:String =ViewObj.GetProperties("Color");
			var panle:MovieClip = McPool.borrowRes(_veilArr[int(color)-1]) as MovieClip; 
			if(panle==null)
				return;
			mc.content["addChildAt"](panle,(mc.content as DisplayObjectContainer).getChildIndex(mc.content["up"])-1);
			panle.x=5;
			panle.y=5
			mc.data.HandleProperties("Veil",panle);
			mc.data.HandleProperties("date",ViewObj);
//			mc["data"]=ViewObj;
		}
		private function removeAllVeil():void
		{
			for(var i:String in _eqCellArr)
			{
				removeVeil(_eqCellArr[i]);
			}
		}
		/**
		 *删除遮罩 
		 * @param mc
		 * 
		 */		
		private function removeVeil(mc:NxClip):void
		{
			if(mc.data.CheckProperties("Veil"))
			{
				var url:String=mc.data.GetProperties("Veil").url;
				McPool.returnRes( url, mc.content["removeChild"](mc.data.GetProperties("Veil")));
				mc.data.DeleteProperties("date");
				mc.data.DeleteProperties("Veil");
			}
		}
		private function onAddHandle(PropertiesName:String,PropertiesValue:ViewObject,data:*):void
		{
//			var index:int =int(PropertiesValue.ObjKey);
//			var mc:MovieClip = ui.actorGroup.getItemByIndex(index);
			if(!PropertiesValue.GetProperties("EquipType"))return ;
			var nx:NxClip=_eqCellArr[GameDefine.EQPOS_HASH_MAP[PropertiesValue.GetPropertiesEx("EquipType")]-1]
//			trace("MyPropertyLogic.Init()",nx.defaultImage,nx.defaultImage.visible,nx.defaultImage.stage);
			nx.data.HandleProperties(DATAOBJ,PropertiesValue);
			(nx.data.GetProperties(EQUIP) as NxClip).source=ResourcesPath.getPropsURL( PropertiesValue.GetProperties("Photo"));
			
			nx.content["up"].visible=false;
			updateFashionBtn(PropertiesValue);
			//是否显示可以升级图标
			if(nx.data.CheckProperties("date"))
			{
				removeVeil(nx);
			}
			addVeil(PropertiesValue,nx);
			//卷轴ID
			var id:int=PropertiesValue.GetPropertiesEx("UpgradeScroll");
			if(id !=0)
			{
				var vieobj:ViewObject=ComposeItemLogic.getInstance().searchItem(id,2);
				//合成的产物
				var obj:Object =ComposeItemLogic.getInstance().readItemIni(vieobj)
				if(vieobj&&obj)
				{
					if(_role.getPlayerLevel()>=obj["NeedLevel"])
					{
						nx.content["up"].visible = (nx.content as MovieClip).mouseChildren=nx.content["up"].mouseEnabled=true;
						//date 保存 需要的卷轴
						nx.data.HandleProperties("date",vieobj);
					}
				}
			}
			
		}
		
		private function updateFashionVisible():void
		{
			if(_actorGroup.rollArr[_actorGroup.currentIndex] is RoleVo)
			{
				var view:View =ModelLocator.getInstance().scene.GetView(View.VIEWPORT_EQUIP);
				if(view !=null)
				{
					var isHaveFashion:Boolean = false;
					for(var property:String  in view.Properties) 
					{
						if(int(property) == GameDefine.Fashion)
						{
							isHaveFashion = true;
							break;
						}
						
					}
					_ui.veilBtn.visible = isHaveFashion;
				}
			}
			
		}
		private function updateFashionBtn(PropertiesValue:ViewObject):void
		{
			if(PropertiesValue.GetProperties("EquipType") == "Fashion")
			{
				fashion = PropertiesValue.GetProperties("ModelSwitch");
				if(fashion == FASHION_SHOW)
				{
					ui.veilBtn.gotoAndStop(VEIL);
				}
				else
				{
					ui.veilBtn.gotoAndStop(SHOW);
				}
			}
			updateFashionVisible();
		}
		private function onRemoveHandle(PropertiesName:String,PropertiesValue:*,data:*):void
		{
			var nx:NxClip=_eqCellArr[GameDefine.EQPOS_HASH_MAP[PropertiesValue.GetPropertiesEx("EquipType")]-1]
			clearEq(GameDefine.EQPOS_HASH_MAP[PropertiesValue.GetPropertiesEx("EquipType")]-1)
			removeVeil(nx);
			updateFashionBtn(PropertiesValue);
		}
		private function updateFunc(PropertiesName:String,PropertiesValue:*,data:*):void
		{
			updateFashionBtn(PropertiesValue);
		}
		private function onremovePerHandle(PropertiesName:String,PropertiesValue:Array,data:*):void
		{
//			trace("Error~MyPropertyLogic.onremovePerHandle(PropertiesName, PropertiesValue, data)","这怎么可能被调用");
		}
		private function refreshVisible():void
		{
			if(_ui.battleBtn.label==BATTLE_LAB)
			{
				_ui.battleBtn.visible=_role.getPlayerLevel()>=int(_lvlObj["embattle"]);
			}
			else
			{
				_ui.battleBtn.visible=_role.getPlayerLevel()>=int(_lvlObj["impart"])
			}
			_ui.chengskillBtn.visible =(_role.getPlayerLevel()>=int(_lvlObj["skill"]))&&(!_actorGroup.currentIndex);
			
		}
		public function set myLevel(value:int):void
		{
//			MyPropertyUI_LVL
			refreshVisible()
			_ui.partnerBtn.visible=value>=int(_lvlObj["partner"]);
			_ui.medicineBtn.visible=value>=int(_lvlObj["medicine"]);
			_ui.detailLab.visible=_ui.actorVisual.buttonMode=_ui.actorVisual.mouseChildren=_ui.actorVisual.mouseEnabled=value>=int(_lvlObj["details"]);
		}
		/**
		 *得到当前绑定的武器视图号 
		 * @return  ViewID
		 * 
		 */		
		public function getEquipView():Number
		{
			//绑定装备
			if(_actorGroup.currentIndex	==	0)
			{
				_eqObjViewflag=	View.VIEWPORT_EQUIP
			}
			else 
			{
				_eqObjViewflag=geteqView(_actorGroup.rollArr[_actorGroup.currentIndex].GetPropertiesEx(CONFIGID));
				
			}
			return _eqObjViewflag;
		}
		/**
		 *得到伙伴 武器视图id 
		 * @param partnerConfigID
		 * @return 8
		 * 
		 */		
		private function geteqView(partnerConfigID:String):Number
		{
			var arr:Array=getPartnerViewsById(int(partnerConfigID))
			var id:int;
			if(!arr||!arr.length)
			{
				id	=	0;
			}
			else
			{
				id=arr[1]
			}
			return id;
		}
		internal function findEqEmptyViewID(eqType:String):int
		{
			var viewid:int;
			var eqview:View;
			
			for each (var i:ObjectData in _actorGroup.rollArr) 
			{
				viewid=i==_role?View.VIEWPORT_EQUIP:geteqView(i.GetPropertiesEx("ConfigID"));
				eqview=_model.scene.GetView(viewid);
				if(!isEqExist(eqType,eqview))
					return viewid;
			}
			if(!_initAlready)
			{
				var vieww:View=_model.scene.GetView(View.VIEWPORT_PARTNER);
				var vO:Object=vieww.Properties;
				for  (var j:String in vO) 
				{
					if(Number(j))
					{
						i=vO[j];
						 viewid=i==_role?View.VIEWPORT_EQUIP:geteqView(i.GetPropertiesEx("ConfigID"));
						 eqview=_model.scene.GetView(viewid);
						if(!isEqExist(eqType,eqview))
							return viewid;
					}
				}
			}
			return -1;
		}
		/**
		 *装备是否存在 
		 * @param eqType
		 * @param view 
		 * @return 
		 * 
		 */		
		private function isEqExist(eqType:String,view:View):Boolean
		{
			for  (var i:String in view.Properties) 
			{
				if(Number(i))
				{
					var viewPort:ViewObject=view.GetPropertiesEx(i);
					if(viewPort.GetPropertiesEx("EquipType")==eqType)
						return true 
				}
			}
			return false;
		}
		/**
		 *得到当前装备功法的viewid 
		 * @return 
		 * 
		 */		
		public function getKungfuViewID():int
		{
			//绑定装备
			if(_actorGroup.currentIndex	==	0)
			{
				_eqObjViewflag=	View.VIEWPORT_KUNGFU
			}
			else 
			{
				var arr:Array=getPartnerViewsById(_actorGroup.rollArr[_actorGroup.currentIndex].GetPropertiesEx(CONFIGID));
				if(arr&&arr.length)
				{
					_eqObjViewflag=arr[4];
				}
				else
				{
//					trace("Error~MyPropertyLogic.getKungfuViewID()怎么可能没有");
					_eqObjViewflag=0
				}
			}
			return _eqObjViewflag;
		}
		public function get isPartnerNotEmbattle():Boolean
		{
			if(_isBind)
			return _actorGroup.isPartnerNotEmbattle
			BeforeShow();
			afterhide();
			return _actorGroup.isPartnerNotEmbattle;
		}
//		/**
//		 * 检查装备是不是可以升级 
//		 * @param obj
//		 * @return 
//		 * 
//		 */		
//		private function checkIsCan(obj:Object):Boolean
//		{
//			var Count:int;
//			var id:int=obj.GetPropertiesEx("UpgradeScroll");
//			Count=ComposeItemLogic.getInstance().searchItem(id,1);
//			if(Count>0)
//			{
//				return true;
//			}
//			else
//			{
//				return false;
//			}
//		}
	}
}